package com.loby.controller;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.loby.data.base.pojo.TMonForwardInfos;
import com.loby.data.base.pojo.TMonMonitorStation;
import com.loby.data.history.pojo.MHisDataTables;
import com.loby.data.mapper.AdministrativeDivisionMapper;
import com.loby.data.mapper.DataTableMapper;
import com.loby.data.mapper.MonitorStationMapper;
import com.loby.data.redis.pojo.RedisRealData;
import com.loby.monitor.client.propertie.ClientProperty;
import com.loby.service.BaseMonitorDataServiceApiImpl;
import com.loby.util.RedisOperator;
import com.loby.zk.util.PropertyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class AdministrativeDivisionController {

    @Autowired
    AdministrativeDivisionMapper divisionMapper;

    @Autowired
    DataTableMapper dataTableMapper;

    @Autowired
    MonitorStationMapper monitorStationMapper;

    @Autowired
    RedisOperator redis;

    @Autowired
    BaseMonitorDataServiceApiImpl baseMonitorDataServiceApi;

    @RequestMapping("/index/{id}")
    public Object index(@PathVariable("id") Long id){

        List<MHisDataTables> tables = dataTableMapper.getTablesByStationId(id);
        TMonMonitorStation station= monitorStationMapper.getMonitorStationById(id);
        List<TMonForwardInfos> infos = monitorStationMapper.getForwardInfosByStationId(id);
        ClientProperty property = PropertyUtil.getProperty(station, tables, infos);
        return property;

    }
    @RequestMapping("/from")
    public Object ss(){

        List realDatas = redis.getRealDatas("21", "1234567890123");

        RedisRealData realData = JSONObject.parseObject(JSONObject.toJSONString(realDatas.get(0)), RedisRealData.class);

        return realData;

    }

    @RequestMapping("/404")
    public Object in(){
        return "/404.html";

    }



}
